1. Field of the Invention
The invention relates to diagram processing apparatus and method for drawing a diagram.
2. Related Background Art
A conventional printer apparatus uses a drawing method whereby a line (diagram) to be drawn in one page is divided into a line segment (hereinafter, simply referred to as a segment) in which a line from a position (point A shown in FIG. 5) of the largest Y coordinate to a position (point B) at which a drawing direction of the diagram changes (from the Y direction to the -Y direction or from the -Y direction to the Y direction) by 180.degree. for the direction of the portion at the position A or a line from the position A to a position (point C) at which a continuous line is stopped is set to one line, the segment is converted into data of a format called a run length, and the diagram is drawn on the basis of the run length data.
The run length has the X coordinate of a drawing start point and the X coordinate of a drawing end point as a pair of data every scan line. Therefore, run length objects have data of the same size irrespective of the shapes of diagrams so long as heights (differences between the Y coordinates at the top positions and the Y coordinates at the bottom positions) of the target diagrams are equal.
In case of drawing, for example, a diagram as shown in FIG. 5 by using the above conventional drawing method, a continuous line from the start to the end of the drawing is first divided into a segment 1 from the point A to the point B and a segment 2 from the point B to the point C. Each segment is regarded as a closed area consisting of a polygon and a diagram is drawn by fully painting the closed area. The painting of the closed area is performed on the basis of run length data. The run length data is formed every segment. The diagram is drawn in accordance with a procedure such that after the drawing process based on the run length data for the segment was performed, another run length data for the next segment is formed.
According to the above conventional drawing method, however, since the drawing process is once performed for every segment irrespective of a length or shape of the segment, for example, in case of repetitively drawing a segment of a simple shape, a very large number of drawing processes are necessary, so that there is a problem such that a processing speed remarkably deteriorates.
In the conventional drawing library, in order to draw a line of a width of 2 or more, a poly pen corresponding to the line width is formed and pen data is extracted in accordance with the requested line width, thereby drawing the line. The poly pen and its data structure will now be described.
As shown in FIG. 13, according to the poly pen (hereinafter, simply referred to as a pen), a quarter (1/4) circle of the same radius as a line width W is divided in accordance with a proper dividing rule to thereby form poly lines and a vector from a certain summit to the adjacent summit is set to a drawing element (hereinafter, referred to as a pen step). The pen corresponding to one line width starts from a horizontal step and ends at a vertical step.
As shown in FIG. 14, each pen step has a slope, a direction from the center for the summit, and coordinates of the summit as data. Each pen step has the data corresponding to a set of those three kinds of values. Entries to all of the step data are sequentially held from the line width "0" to the maximum width.
Further, in correspondence to each line width, an entry to the horizontal pen step and an entry to the vertical pen step are held as a table. By searching the table, the pen step data of a necessary line width is extracted.
As mentioned above, according to the conventional processes of the pen step data, since the pen step data is continuously stored in the pen step table C from the minimum line width to the maximum cache line width, the value of the designated line width directly becomes the entry to an index A of the horizontal pen step and the entry to an index B of the vertical pen step.
The making of the pen step data will now be described.
Since the poly pen data is line symmetric data in which a slope of 45.degree. is set to a boundary, the data is compressed by the following method and held in order to reduce a memory use amount.
That is, now assuming that increase amounts of x and y from a certain step to the next step of the pen step existing in a range from the horizontal direction to 45.degree. (hereinafter, such a pen step is referred to as an up-step) are set to dx and dy, respectively, increase amounts of the pen step existing in a range from 45.degree. to the vertical direction (hereinafter, such a pen step is referred to as a down-step) are the amounts in which dx and dy of the up-steps existing at the position where they are symmetrical with respect to a line are exchanged. By making (dx, dy) (hereinafter, referred to as a step relation) correspond to each pen step as a set of data, the pen step data can be formed from those values.
For one step relation, two cases of the up-step and down-step are considered as a slope of the pen step. Therefore, as shown in FIG. 15, as data tables, the following three tables are prepared,
(1) Step relation table (hereinafter, referred to as RelTable) PA1 (2) Slope table in case of the up-step (hereinafter, referred to as an UpSlopeTable) PA1 (3) Slope table in case of the down-step (hereinafter, referred to as DownSlopeTable) PA1 (4) Table in which those entries are made correspond to the up-steps of all of the line widths (hereinafter, referred to as a StepTable) PA1 (5) Table shown in FIG. 15 in which the line width and StepTable are made correspond (hereinafter, referred to as a PenTable) PA1 discriminating a final line edge shape of the current segment; temporarily reading out a next command when it is judged that the final line edge shape is a predetermined shape; predicting a shape of the next segment on the basis of the next command; PA1 discriminating whether the current segment and the next segment exist on a same scan line or not on the basis of the predicted shape of the next segment; and performing drawing processes of the current segment and the next segment in a lump when it is judged that the current segment and the next segment don't exist on the same scan line.
thereby enabling those tables to be searched by the same entry.
Further, by making the following tables,
the poly pen data is searched from the line width and the pen step data can be formed.
Processes of the data which are executed from the generation of a request to designate a line width to the drawing of a pen will now be described with reference to a flowchart shown in FIG. 16.
FIG. 16 is a flowchart showing an example of a processing procedure of data which is executed from the generation of the line width designation request to the drawing of the pen in a conventional output apparatus. Reference numerals (1) to (10) denote processing steps.
A check is made to see if the corresponding pen has been cached after the line width was designated (1). If YES, step (10) follows and the pen step data is searched (10). The processing routine advances to step (7).
If NO in the judgment in step (1), a check is made to see if the compressed data of the corresponding pen has been held or not (2). If YES, step (9) follows. The compressed data is searched and the processing routine is returned to step (5).
If NO in the judgment in step (2), poly pen data is formed (3) and converted into compressed data (4) and is developed into pen step data (5). The pen is cached into an RAM area (6). The pen is selected (7). A drawing process is executed (8).
The holding of the pen step data and compressed data will now be described hereinbelow.
In the conventional technique, after the poly pen data corresponding to all of the line widths from the minimum line width (0) to the maximum line width was formed, the data is compressed and stored into a file and is held into an ROM area built in the printer in advance. Further, the compressed data of the line width which is considered to be frequently used at the time of the initialization of the program is developed in advance and the pen step data is formed and held as data table into the RAM area (such data is referred to as a cache pen).
Thus, as shown in FIG. 17, when a line width designation command is generated during the execution of a program, if the requested width has already been developed as a cache pen, the entry is returned as it is. When the width is not cached, the compressed data stored in the ROM is read out and developed and the pen step data is formed and used.
As mentioned above, by storing the compressed data into the ROM, the memory use amount in the RAM area is reduced and the pen step data which is frequently used is cached into the RAM area, thereby enabling the line width to be efficiently selected.
As mentioned above, in order to use the poly pen corresponding to a certain line width, it is necessary to pass through a converting path comprising a poly pen data forming process (first process), a converting process to the compressed data (second process), and a developing process to the pen step data (third process). Although the processing procedure can be started from any data format, if it is started from the first process of making the poly pen data, an area to previously hold the data is unnecessary and the memory use amount is minimum. However, there is a problem such that it takes a long time to form the poly pen data. If the pen step data in the third process is formed in advance, although the making time is shortest, there is a problem such that a large capacity of area to hold the data is needed.
Since the number of compressed data or cache pens which can be held in advance depends on the RAM memory capacity of a printer, it is necessary to use a structure which can be switched in accordance with the situation by a method such that in accordance with the memory that is installed, when the memory capacity is small, ranges of the compressed data and cache pens which are held are reduced and a data forming range is dynamically increased in response to the line width designation request, and in the case where the memory capacity is sufficient, the ranges of the compressed data and cache pens which are held are increased and the data forming range is dynamically reduced in response to the line width designation request, or the like.
According to the above conventional method, however, the pen to be previously cached into the pen step table is limited to the continuous data from the minimum line width to the maximum cache line width and only one pen step data which is newly formed from the compressed data or poly pen data is also cached.
Therefore, when the memory capacity of the RAM installed is small, if a predetermined amount of cache pens is possessed, there is a possibility such that the pen of a large width cannot be developed. It is necessary that the number of cache pens and the number of caching times of the create pens can be varied.
Hitherto, when a line to be drawn in one page has a width, the line is divided into lines as shown in FIG. 26 and each line is regarded as a polygon and is held as a data structure called a run length which is used for painting the closed area.
The run length holds the X coordinate of the drawing start point and the X coordinate of the drawing end point as a pair of data every scan line. Therefore, the run length objects have the same amount of data irrespective of the shape of the diagrams so long as the heights are equal.
In case of drawing each line, the run length object corresponding to the line data is formed and the line is drawn.
According to the conventional method, however, when the number of scan lines increases due to a high resolution of a printer, an enlargement in paper size, or the like, a memory of a large capacity is necessary at the time of the drawing process in association with an increase in data amount per page and data has to be formed with respect to all of the scan lines, so that a problem of the reduction of a processing speed occurs.
As a data format for a closed diagram, there is a format called a trapezoid other than the run length.
Although the trapezoid has the right and left drawing positions for one scan line as data in a manner similar to the run length, it doesn't have the X coordinates of the right and left positions with respect to all of the scan lines as in the run length. However, an offset (difference of the X coordinates) from one-preceding point, a slope (slope of an edge) to the next point, and the number of scan lines between those two points are possessed as a set of data every right and left points of the diagram. The X coordinate of each scan line is calculated and obtained from the set of data.
As mentioned above, until the slope of an outline changes, even if the number of scan lines increases, the data amount doesn't increase. Therefore, the trapezoid is a data format that is particularly effective with respect to a diagram in which a change in slope is relatively small, namely, the number of straight lines is large. When developing a bit map by a hardware, there is also an advantage such that by inputting the data in the trapezoid format, the developing process can be performed earlier because of the characteristics of the hardware. Therefore, when the line having a width is regarded as a polygon, there is also a case where by possessing the data as a trapezoid rather than the run length, it is advantageous under certain conditions. According to the trapezoid, as the number of changes of the slope is small, the number of dividing times decreases irrespective of the size of diagram and the processes can be more efficiently performed. Therefore, in case of a diagram whose slope frequently changes, a superiority of the processing efficiency is not so higher as compared with the case of the run length. Thus, a higher efficiency is derived by processing a line edge portion of a special shape, a joint portion of segments, or the like by run length instead of trapezoid.
In order to process such line edge or joint portion by run length and to process a portion having a predetermined slope by trapezoid, the entire line constructed as one run length needs to be divided into different objects of the run length and trapezoid. As the number of objects increases, the processing efficiency also deteriorates. Therefore, in the case where a height of portion to which the trapezoid process is performed is not so high, the advantage due to the execution of the trapezoid process is set off by a disadvantage such that the number of objects increases, so that the trapezoid process is effective in the case where the height of segment is relatively high.